package com.xyauto.theme.bean;

import android.os.Parcel;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.xyauto.theme.App;
import com.xyauto.theme.utils.SelectManager;

import java.util.ArrayList;
import java.util.List;

public class LocalThemeBean implements IThemeBean {

    private String fileName;
    private String previewImage;
    private String apkPath;
    private ArrayList<String> previewImages;


    public LocalThemeBean(String fileName, String previewImage, String apkPath, ArrayList<String> images) {
        this.fileName = fileName;
        this.previewImage = previewImage;
        this.apkPath = apkPath;
        this.previewImages = images;
    }


    public static final Creator<LocalThemeBean> CREATOR = new Creator<LocalThemeBean>() {
        @Override
        public LocalThemeBean createFromParcel(Parcel in) {
            return new LocalThemeBean(in);
        }

        @Override
        public LocalThemeBean[] newArray(int size) {
            return new LocalThemeBean[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    protected LocalThemeBean(Parcel in) {
        fileName = in.readString();
        previewImage = in.readString();
        apkPath = in.readString();
        previewImages = in.createStringArrayList();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(fileName);
        dest.writeString(previewImage);
        dest.writeString(apkPath);
        dest.writeStringList(previewImages);
    }


    @Override
    public boolean isSelected() {
        return SelectManager.INSTANCE.isSelectTheme(fileName);
    }

    @NonNull
    @Override
    public String getName() {
        return fileName;
    }

    @NonNull
    @Override
    public String getPreviewImage() {
        return previewImage;
    }


    @Nullable
    @Override
    public String getApkPath() {
        return apkPath;
    }

    @Nullable
    @Override
    public String getUrlPath() {
        return null;
    }

    @Override
    public boolean isExists() {
        return true;
    }

    @NonNull
    @Override
    public String getVersion() {
        return App.Companion.findLauncherVer();
    }

    @Nullable
    @Override
    public List<String> getPreviewImages() {
        return previewImages;
    }
}
